package csse3004.GD.PM;

import java.util.ArrayList;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Mamdouh 41942989
 */
public class ViewAnswerController implements Controller{
    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
        
        if (hsr.getParameter("qid") != null) {
            int pid = Integer.parseInt(hsr.getParameter("qid"));
            logger.info(pid);
            // use db function(qid)
        }
        
        ArrayList<ViewAnswer> resultList = new ArrayList<ViewAnswer>();
        resultList = ViewAnswer.genTempAnswer();
        return new ModelAndView("viewAnswer", "searchResult", resultList);  
    }
    
    /*
     * TODO CAPTAIN THOMAS.L.MCNAIR BSC, SSC
     * 
     * Function which will retrieve all answers from a specific poll
     */
}